<?php
/*
# ------------------------------------------------------------------------
# JA Teline III - Version 1.3 - Licence Owner jSharing.COM
# ------------------------------------------------------------------------
# Copyright (C) Lifetime Joomla Just for Sharing, Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: Joomla Just for Sharing
# Websites:  http://jsharing.com -  http://jsharing.net
# This file may not be redistributed in whole or significant part.
# ------------------------------------------------------------------------
*/

$contents = $helper->_sections;

$catorsec 				= 	trim( $params->get( 'catorsec' ));

$showcreater			= 	$params->get( 'showcreater', 0 );
$showdate 				= 	$params->get( 'showdate', 0 );
$showimage 				= 	$params->get( 'showimage', 0 );
$autoresize 			= 	intval (trim( $params->get( 'autoresize', 0) ));
$img_w 					= 	intval (trim( $params->get( 'width', 100 ) ));
$img_h 				= 	intval (trim( $params->get( 'height', 100 ) ));
$img_align 					= $params->get( 'align' , 'left');

$maxchars 				= 	intval (trim( $params->get( 'maxchars', 200 ) ));
$introitems 				= 	intval (trim( $params->get( 'introitems', 1 ) ));
$linkitems 				= 	intval (trim( $params->get( 'linkitems', 0 ) ));

$showreadmore 				= 	intval (trim( $params->get( 'showreadmore', 1 ) ));
$showcattitle 			= 	trim( $params->get( 'showcattitle' ));
$hiddenClasses 				= 	trim( $params->get( 'hiddenClasses', '' ) );

$cols = intval (trim( $params->get( 'cols', 2 ) ));
if (!$cols) return;
$width = 99.9/$cols;

?>

<div id="ja-zinwrap">
<div id="ja-zin" class="ja-movable-container clearfix">
<?php
	$t = 0;
	foreach ($contents as $section) :
		$cols = intval (trim( $params->get( 'cols', 2 ) ));
		$cats = count($section->categories);
		$sid = $section->section->id;
		$slug = $section->section->slug;
		$stitle = $section->section->title;
		$sdesc = $section->section->description;
		$col=0;
		if (!$sid) continue;
		$slink   = JRoute::_(ContentHelperRoute::getSectionRoute($slug));
		$pos = $t==0?'row-first':($t == count($contents)-1?'row-last':'');
		$theme = $section->theme;
		$t++;
		$s_showimage = $helper->getUserSetting ($sid, 'showimage', $showimage);
		$s_introitems = $helper->getUserSetting ($sid, 'introitems', $introitems);
		$s_linkitems = $helper->getUserSetting ($sid, 'linkitems', $linkitems);
		
?>
	<div class="article_row <?php echo "cols$cols $pos";?> ja-zintheme-<?php echo "$theme";?> clearfix">
		<div class="ja-zinsec clearfix">
			<h2>
				<a href="<?php echo $slink;?>" title="<?php echo trim(strip_tags($sdesc));?>">
					<span><?php echo $stitle;?></span>
				</a>
			</h2>
		<?php if (defined("JA_USERSETTING_PLUGIN")):?>
		{jausersetting modid=<?php echo $module->id; ?> group=<?php echo $sid; ?> class=ja-usersetting idReload=ja-zinwrap}
		<?php endif;?>
		</div>
		<?php		
		for ($z = 0; $z < $cols; $z ++) :
			$cls = $cols==1?'full':($z==0?'left':($z==$cols-1?'right':'center'));
			$k = $z;
			$pos = $z==0?'col-first':($z == $cols-1?'col-last':'');
			$col++;
		?>	  
		<div class="article_column <?php echo "column$col $pos";?>">
			<?php for ($y = 0; $y < ($cats / $cols) && $k<$cats; $y ++) :
			$cat = $section->categories[$k];
			$path = JModuleHelper::getLayoutPath($module->module, 'blog_item');
			if (file_exists($path)) {
				require($path);
			}
			$k += $cols;
			endfor; ?>
		</div>
		<?php endfor; ?>
	</div>
<?php	
	endforeach;
?>
</div>
</div>
<script type="text/javascript">
/* <![CDATA[ */
	if (typeof JADDModules != 'undefined') new JADDModules($$("#ja-zinwrap .ja-movable-container"), {src_collap_1:src_collap_1, src_collap_2:src_collap_2, 'cookieprefix':'', title: '.ja-zinsec'});
/* ]]> */
</script>